feat(agent): add Gemini CLI install target#57
Conversation
📝 WalkthroughWalkthroughThis PR generalizes agent installation to a multi-skill model, adds gemini managed-section support, updates install/list and init flows to carry skill information, and revises related tests and documentation for the new target and Python test code workflows. ChangesMulti-skill agent registry and CLI
Estimated code review effort: 4 (Complex) | ~60 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/commands/agent.ts (1)
499-544: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winReport the composed managed-file byte count in dry-run output.
Line 534 computes
wouldBeBytes, but Line 543 still recordsbytesfrom only the managed section. For an append/replace into an existingAGENTS.md/GEMINI.md, the dry-run “would write” size under-reports the actual resulting file size.Proposed fix
- const bytes = Buffer.byteLength(section, 'utf8'); let wouldBeContent = section; @@ - dryRunLines.push({ abs, bytes, note: 'managed section' }); + dryRunLines.push({ abs, bytes: wouldBeBytes, note: 'managed section' });🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/commands/agent.ts` around lines 499 - 544, The dry-run output in the agent command reports the wrong byte count because `dryRunLines.push` in `src/commands/agent.ts` still uses `bytes` instead of the computed `wouldBeBytes`. Update the dry-run record for the managed section so it reflects the final composed file size after `classifySection`/`composeManagedFile` logic, including append and replace cases. Keep the warning and result behavior unchanged, but make the reported “would write” size match the actual post-write content.
🧹 Nitpick comments (4)
src/commands/agent.ts (1)
325-330: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winGeneralize the managed-section comments beyond Codex.
Gemini now also uses managed-section mode, so these comments should describe “managed-section targets” rather than Codex specifically.
Proposed wording cleanup
- * (`[skill]`); the codex managed-section target produces ONE result whose + * (`[skill]`); managed-section targets produce ONE result whose * section aggregates every installed skill (`[...skills]`).- // single AGENTS.md (so every codex row shares that path — truthful, since both + // single root instruction file (so managed-section rows share that path — truthful, since bothAlso applies to: 764-767
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/commands/agent.ts` around lines 325 - 330, The comments on the skill result shape in agent.ts are too Codex-specific and should be generalized to cover all managed-section targets. Update the documentation around the skills field and the related managed-section comment block (including the matching comment near the later section) so they refer to “managed-section targets” instead of “Codex,” while keeping the behavior description about own-file targets versus aggregated managed-section results.src/commands/agent.test.ts (1)
1418-1440: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd Gemini repeat-install coverage for the managed block.
This new suite covers append, but the PR safety claim also depends on repeated Gemini installs replacing exactly one TestSprite block while preserving surrounding
GEMINI.mdcontent. Add a second run/assertion for exactly one begin/end sentinel and unchanged user text.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/commands/agent.test.ts` around lines 1418 - 1440, The new Gemini append test in runInstall only verifies the first install path, but it should also cover repeat-install behavior for the managed section. Extend the existing runInstall — gemini managed-section: append test to perform a second run with the same target and assert that GEMINI.md still preserves the user content while containing exactly one managed block bounded by TARGETS.gemini.managedSection!.begin and TARGETS.gemini.managedSection!.end. Use the existing runInstall, TARGETS.gemini.managedSection, and makeMemFs helpers to confirm repeated installs replace the TestSprite block instead of duplicating it.src/lib/agent-targets.test.ts (1)
694-716: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd a Gemini onboard rendering assertion.
The new Gemini target is installed with
DEFAULT_SKILLS, but this suite only exercises Gemini withtestsprite-verify. Add one test fortestsprite-onboardso the sharedGEMINI.mdpath and managed-section contribution stay covered.Proposed test coverage
it('renderForTarget("gemini") without body arg uses the managed-section asset', () => { const result = renderForTarget('gemini', 'testsprite-verify'); expect(result.content).toContain('testsprite test run'); expect(result.content).not.toContain('name: testsprite-verify'); expect(result.content).not.toContain('alwaysApply:'); }); + + it('renderForTarget("gemini") supports the onboard managed-section contribution', () => { + const result = renderForTarget('gemini', 'testsprite-onboard'); + expect(result.path).toBe('GEMINI.md'); + expect(result.content).toBe(ONBOARD_CODEX_LINE); + expect(result.content).not.toContain('---'); + }); });🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/lib/agent-targets.test.ts` around lines 694 - 716, Add a Gemini onboarding coverage test in the existing renderForTarget("gemini") suite so the shared GEMINI.md path is verified for testsprite-onboard as well as testsprite-verify. Reuse renderForTarget and assert that the onboard target resolves to GEMINI.md and includes the managed-section content expected from DEFAULT_SKILLS, keeping the assertion alongside the current gemini content-integrity tests.src/lib/agent-targets.ts (1)
136-140: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winUpdate
pathFordocs to include Gemini’s shared path.The comment still says only Codex lands in a shared root file, but
geminialso ignoresskilland returnsGEMINI.md.Proposed JSDoc tweak
- * skills coexist; the codex target always lands at the single shared `AGENTS.md` - * (every skill's codex contribution is merged into one managed section there). + * skills coexist; managed-section targets land at shared root instruction files + * (`AGENTS.md` for codex, `GEMINI.md` for gemini), where every selected skill's + * contribution is merged into one managed section.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/lib/agent-targets.ts` around lines 136 - 140, The JSDoc for pathFor is outdated: it says only codex uses a shared root file, but gemini also ignores the skill and maps to a single shared file. Update the comment near pathFor in agent-targets.ts to mention both codex and gemini shared landing paths, and keep the target-specific behavior clear for own-file targets.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/lib/agent-targets.ts`:
- Around line 322-326: The remaining renderForTarget call site is still passing
only the target, so the missing second argument is being treated as the skill id
and causing the unknown skill failure. Update the call in the agent install e2e
test to pass both the AgentTarget and the intended skill string, matching the
new renderForTarget(t, skill, body?) signature and other call sites.
---
Outside diff comments:
In `@src/commands/agent.ts`:
- Around line 499-544: The dry-run output in the agent command reports the wrong
byte count because `dryRunLines.push` in `src/commands/agent.ts` still uses
`bytes` instead of the computed `wouldBeBytes`. Update the dry-run record for
the managed section so it reflects the final composed file size after
`classifySection`/`composeManagedFile` logic, including append and replace
cases. Keep the warning and result behavior unchanged, but make the reported
“would write” size match the actual post-write content.
---
Nitpick comments:
In `@src/commands/agent.test.ts`:
- Around line 1418-1440: The new Gemini append test in runInstall only verifies
the first install path, but it should also cover repeat-install behavior for the
managed section. Extend the existing runInstall — gemini managed-section: append
test to perform a second run with the same target and assert that GEMINI.md
still preserves the user content while containing exactly one managed block
bounded by TARGETS.gemini.managedSection!.begin and
TARGETS.gemini.managedSection!.end. Use the existing runInstall,
TARGETS.gemini.managedSection, and makeMemFs helpers to confirm repeated
installs replace the TestSprite block instead of duplicating it.
In `@src/commands/agent.ts`:
- Around line 325-330: The comments on the skill result shape in agent.ts are
too Codex-specific and should be generalized to cover all managed-section
targets. Update the documentation around the skills field and the related
managed-section comment block (including the matching comment near the later
section) so they refer to “managed-section targets” instead of “Codex,” while
keeping the behavior description about own-file targets versus aggregated
managed-section results.
In `@src/lib/agent-targets.test.ts`:
- Around line 694-716: Add a Gemini onboarding coverage test in the existing
renderForTarget("gemini") suite so the shared GEMINI.md path is verified for
testsprite-onboard as well as testsprite-verify. Reuse renderForTarget and
assert that the onboard target resolves to GEMINI.md and includes the
managed-section content expected from DEFAULT_SKILLS, keeping the assertion
alongside the current gemini content-integrity tests.
In `@src/lib/agent-targets.ts`:
- Around line 136-140: The JSDoc for pathFor is outdated: it says only codex
uses a shared root file, but gemini also ignores the skill and maps to a single
shared file. Update the comment near pathFor in agent-targets.ts to mention both
codex and gemini shared landing paths, and keep the target-specific behavior
clear for own-file targets.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: a616caba-7f61-492f-8194-260254a50514
⛔ Files ignored due to path filters (1)
test/__snapshots__/help.snapshot.test.ts.snapis excluded by!**/*.snap
📒 Files selected for processing (6)
DOCUMENTATION.mdREADME.mdsrc/commands/agent.test.tssrc/commands/agent.tssrc/lib/agent-targets.test.tssrc/lib/agent-targets.ts
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (2)
test/e2e/agent-install.e2e.test.ts (2)
146-244: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winMissing gemini managed-section content-integrity test.
This suite adds a thorough codex-specific test (Lines 209–244) verifying exactly-one sentinel pair, ordering, and both skills' content in
AGENTS.md. Sincegeminiis now a secondmanaged-sectiontarget using its own sentinel pair (GEMINI_MANAGED_SECTION_BEGIN/END), and preserving user content around this sentinel-delimited block is a headline feature of this PR, there's no equivalent test verifyingGEMINI.md's managed-section behavior (sentinel presence/count, ordering, content, and no-frontmatter-fence check).Without this, the exact behavior described in the PR objectives — "existing content outside the TestSprite block is preserved" for
GEMINI.md— is untested at the e2e level.Suggested addition (mirrors the codex test)
it('gemini GEMINI.md contains ONE managed section with both verify and onboard content', () => { const tmpDir = freshTmpDir(); runCli(['agent', 'install', '--target=gemini', '--dir', tmpDir, '--output', 'json']); const filePath = join(tmpDir, TARGETS.gemini.path); const content = readFileSync(filePath, 'utf8'); const beginCount = ( content.match( new RegExp(GEMINI_MANAGED_SECTION_BEGIN.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), 'g'), ) ?? [] ).length; const endCount = ( content.match( new RegExp(GEMINI_MANAGED_SECTION_END.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), 'g'), ) ?? [] ).length; expect(beginCount).toBe(1); expect(endCount).toBe(1); expect(content.indexOf(GEMINI_MANAGED_SECTION_BEGIN)).toBeLessThan( content.indexOf(GEMINI_MANAGED_SECTION_END), ); expect(content).toContain('TestSprite Verification Loop'); expect(content).toContain('First-time setup'); expect(content.startsWith('---')).toBe(false); });🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@test/e2e/agent-install.e2e.test.ts` around lines 146 - 244, Add an e2e test for the gemini managed-section target to match the existing codex coverage: after running agent install for TARGETS.gemini, read the generated GEMINI.md and verify exactly one GEMINI_MANAGED_SECTION_BEGIN and GEMINI_MANAGED_SECTION_END pair exists in the correct order, the content includes both the verification and onboard strings, and the file does not start with frontmatter fences. Mirror the structure of the existing codex test in test/e2e/agent-install.e2e.test.ts so the gemini-specific managed-section behavior is validated with the same sentinel-count and content-integrity checks.
433-472: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winMulti-target install test omits the new
geminitarget.The explicit CLI arg list
--target=claude,cursor,cline,antigravity,codex(Line 433) excludesgemini, even though the matrix coverage guard (Lines 822-830 in this same file) enforces thatTARGETSincludesgemini. This leaves the multi-target install path (targets + skills together in one invocation) untested for the very target this PR introduces.Suggested fix
- it('--target=claude,cursor,cline,antigravity,codex writes all targets + skills, exit 0', () => { + it('--target=claude,cursor,cline,antigravity,codex,gemini writes all targets + skills, exit 0', () => { const tmpDir = freshTmpDir(); const result = runCli([ 'agent', 'install', - '--target=claude,cursor,cline,antigravity,codex', + '--target=claude,cursor,cline,antigravity,codex,gemini', '--dir', tmpDir, '--output', 'json', ]);🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@test/e2e/agent-install.e2e.test.ts` around lines 433 - 472, The multi-target install e2e test in the agent install spec is missing coverage for the newly added gemini target, so the combined install path is not exercised for it. Update the target list used by the `it('--target=... writes all targets + skills, exit 0')` case to include gemini alongside the existing targets, and make sure the assertions in the loop naturally verify gemini’s installed output according to its `TARGETS[gemini].mode`. Keep the test aligned with the `TARGETS` matrix guard so this scenario covers every supported target introduced by the CLI.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docs/cli-v1-agent-install/onboard-skill-template.md`:
- Around line 20-26: The onboarding boundary is ambiguous because “0–1 tests”
overlaps with the verify path for repos that already have tests. Update the
onboarding guidance in the skill template to make the threshold explicit and
exclusive, and ensure the wording around the TestSprite repo eligibility clearly
routes any repo with at least one existing test to testsprite-verify while
onboarding only truly testless repos.
In `@README.md`:
- Line 70: The README callout and Agent command table are out of sync with the
new Gemini multi-skill flow. Update the setup guidance in README to describe
that `testsprite setup` installs the multi-skill verification flow rather than a
single verification skill, and add `gemini` to the supported agent list in the
Agent command table. Use the existing README sections around the coding-agent
callout and the Agent table to keep the wording consistent.
In `@src/commands/agent.ts`:
- Around line 440-445: Make getManagedSection() target-aware instead of always
caching buildCodexAggregate(skills) for every managed section. Update the
managed-section body selection in agent.ts so the cached aggregate is keyed by
the current target or computed per target, and pass the correct target into
buildCodexAggregate for each ManagedSectionSpec. Ensure --target gemini writes
the Gemini-specific aggregate into GEMINI.md, while codex,gemini installs can
produce distinct managed content for each target.
---
Nitpick comments:
In `@test/e2e/agent-install.e2e.test.ts`:
- Around line 146-244: Add an e2e test for the gemini managed-section target to
match the existing codex coverage: after running agent install for
TARGETS.gemini, read the generated GEMINI.md and verify exactly one
GEMINI_MANAGED_SECTION_BEGIN and GEMINI_MANAGED_SECTION_END pair exists in the
correct order, the content includes both the verification and onboard strings,
and the file does not start with frontmatter fences. Mirror the structure of the
existing codex test in test/e2e/agent-install.e2e.test.ts so the gemini-specific
managed-section behavior is validated with the same sentinel-count and
content-integrity checks.
- Around line 433-472: The multi-target install e2e test in the agent install
spec is missing coverage for the newly added gemini target, so the combined
install path is not exercised for it. Update the target list used by the
`it('--target=... writes all targets + skills, exit 0')` case to include gemini
alongside the existing targets, and make sure the assertions in the loop
naturally verify gemini’s installed output according to its
`TARGETS[gemini].mode`. Keep the test aligned with the `TARGETS` matrix guard so
this scenario covers every supported target introduced by the CLI.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: f9841f74-68d7-46c3-ad9b-01e71690d52d
📒 Files selected for processing (15)
DOCUMENTATION.mdREADME.mddocs/cli-v1-agent-install/onboard-skill-template.mdskills/testsprite-onboard.skill.mdskills/testsprite-verify.codex.mdskills/testsprite-verify.skill.mdsrc/commands/agent.test.tssrc/commands/agent.tssrc/commands/init.tssrc/lib/agent-targets.test.tssrc/lib/agent-targets.tssrc/lib/skill-nudge.test.tssrc/lib/skill-nudge.tstest/e2e/agent-install.e2e.test.tstest/e2e/setup.e2e.test.ts
✅ Files skipped from review due to trivial changes (1)
- DOCUMENTATION.md
🚧 Files skipped from review as they are similar to previous changes (3)
- src/lib/agent-targets.ts
- src/lib/agent-targets.test.ts
- src/commands/agent.test.ts
| one-line `ONBOARD_CODEX_LINE` from the registry, because AGENTS.md is always-on | ||
| with a 32 KiB budget. | ||
| --> | ||
|
|
||
| # TestSprite: onboard a repo with a seed test suite | ||
|
|
||
| Your job is to take a repo that has **no TestSprite tests yet** and leave it with a |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Tighten the onboarding boundary.
0–1 tests conflicts with the later rule that projects which already have tests belong to testsprite-verify. A repo with one existing test matches both skills, so please make the cutoff explicit.
Suggested fix
-- Right after `testsprite setup`, or any time the active project has 0–1 tests.
+- Right after `testsprite setup`, or any time the active project has 0 tests.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@docs/cli-v1-agent-install/onboard-skill-template.md` around lines 20 - 26,
The onboarding boundary is ambiguous because “0–1 tests” overlaps with the
verify path for repos that already have tests. Update the onboarding guidance in
the skill template to make the threshold explicit and exclusive, and ensure the
wording around the TestSprite repo eligibility clearly routes any repo with at
least one existing test to testsprite-verify while onboarding only truly
testless repos.
| ``` | ||
|
|
||
| > **Pointing a coding agent (Claude Code, Cursor, Codex, Cline, …) at TestSprite?** Have it run `testsprite setup` first — that installs the verification skill, so the agent knows how to create, run, and triage tests on its own (instead of guessing from this README). New here? Start with the **[getting-started overview](https://docs.testsprite.com/cli/getting-started/overview)**. | ||
| > **Pointing a coding agent (Claude Code, Gemini CLI, Cursor, Codex, Cline, …) at TestSprite?** Have it run `testsprite setup` first — that installs the verification skill, so the agent knows how to create, run, and triage tests on its own (instead of guessing from this README). New here? Start with the **[getting-started overview](https://docs.testsprite.com/cli/getting-started/overview)**. |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Keep the README aligned with the new Gemini multi-skill flow.
This callout still says testsprite setup installs a single verification skill, and the Agent command table still omits gemini. That leaves the README contradicting the new install behavior and understating the newly supported target.
Also applies to: 113-113
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@README.md` at line 70, The README callout and Agent command table are out of
sync with the new Gemini multi-skill flow. Update the setup guidance in README
to describe that `testsprite setup` installs the multi-skill verification flow
rather than a single verification skill, and add `gemini` to the supported agent
list in the Agent command table. Use the existing README sections around the
coding-agent callout and the Agent table to keep the wording consistent.
| let managedSectionBodyCache: string | undefined; | ||
| const getManagedSection = (managed: ManagedSectionSpec): string => { | ||
| if (managedSectionBodyCache === undefined) { | ||
| managedSectionBodyCache = buildCodexAggregate(skills); | ||
| } | ||
| return buildSection(managedSectionBodyCache, managed); |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Make the managed-section aggregate target-aware.
getManagedSection() always builds its body with buildCodexAggregate(skills), then reuses that cached body for every managed-section target. That means --target gemini still writes the Codex aggregate into GEMINI.md, and a codex,gemini install can only produce identical managed content for both targets.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/commands/agent.ts` around lines 440 - 445, Make getManagedSection()
target-aware instead of always caching buildCodexAggregate(skills) for every
managed section. Update the managed-section body selection in agent.ts so the
cached aggregate is keyed by the current target or computed per target, and pass
the correct target into buildCodexAggregate for each ManagedSectionSpec. Ensure
--target gemini writes the Gemini-specific aggregate into GEMINI.md, while
codex,gemini installs can produce distinct managed content for each target.
Summary
geminiagent target that installs TestSprite guidance intoGEMINI.mdSafety
GEMINI.mduses sentinel-delimited managed-section writes, so existing project instructions outside the TestSprite block are preservedTests
npm run format:checknpm run test -- src/lib/agent-targets.test.ts src/commands/agent.test.ts test/help.snapshot.test.tsnpm run typechecknpm run lintnpm run buildSummary by CodeRabbit
--skillsupport foragent install, enabling single-skill installs and multi-skill selections; install and list results now report selected skills.test code get/putdocumentation to clarify Python outputs and replacement requirements.